package cn.tedu.cool.controller;

import cn.tedu.cool.entity.Cate;
import cn.tedu.cool.mapper.CateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CateController {
    @Autowired(required = false)
    CateMapper cateMapper;
@RequestMapping("/cate/select")
    public List<Cate> select(){
    return cateMapper.select();
}
@RequestMapping("/cate/delete")
    public void deleteById(int id){
    cateMapper.deleteById(id);
}
@RequestMapping("/cate/insert")
public Cate insert(Cate cate){
    if (cate.getName().equals("单品")){
        cateMapper.insert(cate);
return cate;
    }else if (cate.getName().equals("花艺")){
        cateMapper.insert1(cate);
        return cate;
    }else {
        cateMapper.insert2(cate);
        return cate;
    }
}
}
